home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / dvips / special.lpro < prev    next >
Encoding:
Text File  |  1990-09-24  |  7.7 KB  |  300 lines

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %%     header for the \special command
  3. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  4. %   The structure of the PostScript produced by dvips for \special is:
  5. %         @beginspecial
  6. %           - any number of @hsize, @hoffset, @hscale, etc., commands
  7. %         @setspecial
  8. %           - the user's file of PostScript commands
  9. %         @endspecial
  10.  
  11. TeXDict begin
  12. /SDict 200 dict def
  13. SDict begin
  14.  
  15. /@SpecialDefaults
  16.   { /hs 612 def
  17.     /vs 792 def
  18.     /ho 0 def
  19.     /vo 0 def
  20.     /hsc 1 def
  21.     /vsc 1 def
  22.     /ang 0 def
  23.     /CLIP false def
  24.     /BBcalc false def
  25.   } bdf
  26.  
  27. %
  28. %   The following definition sets up the units that hscale/vscale are in.
  29. %   For certain sites this might require change, but it is
  30. %   recommended instead that any macro packages that require
  31. %   hscale/vscale set the units appropriately via
  32. %
  33. %   \special{! /@scaleunit 1 def }
  34. %
  35. %   if global, or
  36. %
  37. %   \special{" /@scaleunit 1 def }
  38. %
  39. %   before each instance if multiple macro packages with
  40. %   different requirements are being used.
  41. %
  42. /@scaleunit 100 def
  43. %       s @hscale  -    set scale factor
  44. /@hscale {@scaleunit div /hsc exch def} bdf
  45. /@vscale {@scaleunit div /vsc exch def} bdf
  46.  
  47. %       d @hsize   -    specify a horizontal clipping dimension
  48. /@hsize {/hs exch def /CLIP true def} bdf
  49. /@vsize {/vs exch def /CLIP true def} bdf
  50.  
  51. %       d @hoffset -    specify a shift for the figure
  52. /@hoffset {/ho exch def} bdf
  53. /@voffset {/vo exch def} bdf
  54.  
  55. %       a @angle   -    set rotation angle
  56. /@angle {/ang exch def} bdf
  57.  
  58. %
  59. %   Here we handle bounding box calculations, if necessary.
  60. %
  61. /@rwi { 10 div /rwi exch def } bdf % rwi will be real width after scaling
  62. /@llx { /llx exch def } bdf
  63. /@lly { /lly exch def } bdf
  64. /@urx { /urx exch def } bdf
  65. /@ury { /ury exch def /BBcalc true def } bdf
  66.  
  67. end % of SDict
  68.  
  69. /@MacSetUp
  70.   { userdict /md known  % if md is defined
  71.       { userdict /md get type /dicttype eq      % and if it is a dictionary
  72.     {
  73.     md begin                             % then redefine some stuff
  74.     /letter {} def
  75.     /note {} def
  76.     /legal {} def
  77.     /od{txpose
  78.         1 0 mtx defaultmatrix dtransform exch atan/pa exch def
  79.         newpath clippath mark
  80.         {transform{itransform moveto}}
  81.         {transform{itransform lineto}}
  82.         { 6 -2 roll transform
  83.           6 -2 roll transform
  84.           6 -2 roll transform
  85.           { itransform 6 2 roll
  86.         itransform 6 2 roll
  87.         itransform 6 2 roll
  88.         curveto
  89.           }
  90.         }
  91.         {{closepath}}
  92.         pathforall newpath counttomark array astore /gc xdf
  93.         pop ct 39 0 put
  94.         10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}if
  95.     }def
  96.     /txpose{
  97.         pxs pys scale ppr aload pop
  98.         por {
  99.         noflips {
  100.             pop exch neg exch translate pop 1 -1 scale
  101.         }if
  102.         xflip yflip and {
  103.             pop exch neg exch translate 180 rotate 1 -1 scale
  104.             ppr 3 get ppr 1 get neg sub neg ppr 2 get
  105.             ppr 0 get neg sub neg translate
  106.         }if 
  107.         xflip yflip not and {
  108.             pop exch neg exch translate pop 180 rotate
  109.             ppr 3 get ppr 1 get neg sub neg 0 translate
  110.         }if
  111.         yflip xflip not and {
  112.             ppr 1 get neg ppr 0 get neg translate
  113.         }if
  114.         }
  115.         {
  116.         noflips {
  117.             translate pop pop 270 rotate 1 -1 scale
  118.         }if
  119.         xflip yflip and {
  120.             translate pop pop 90 rotate 1 -1 scale
  121.             ppr 3 get ppr 1 get neg sub neg ppr 2 get
  122.             ppr 0 get neg sub neg translate
  123.         }if
  124.         xflip yflip not and {
  125.             translate pop pop 90 rotate ppr 3 get
  126.             ppr 1 get neg sub neg 0 translate
  127.         }if
  128.         yflip xflip not and {
  129.             translate pop pop 270 rotate ppr 2 get
  130.             ppr 0 get neg sub neg 0 exch translate
  131.         }if
  132.         }ifelse
  133.         scaleby96 {
  134.         ppr aload pop 4 -1 roll add 2 div 3 1 roll add 2 div 2 copy
  135.         translate .96 dup scale neg exch neg exch translate
  136.         }if
  137.     }def
  138.     /cp {pop pop showpage pm restore}def
  139.         end
  140.       }if
  141.     } if    
  142.   } def
  143.  
  144. %
  145. %   We need the psfig macros.
  146. %
  147. % All software, documentation, and related files in this distribution of
  148. % psfig/tex are Copyright (c) 1987 Trevor J. Darrell
  149. %
  150. % Permission is granted for use and non-profit distribution of psfig/tex 
  151. % providing that this notice be clearly maintained, but the right to
  152. % distribute any portion of psfig/tex for profit or as part of any commercial
  153. % product is specifically reserved for the author.
  154. %
  155. %
  156. % psfigTeX PostScript Prolog
  157. % $Header: /sprite/src/cmds/dvips/RCS/special.lpro,v 1.1 90/02/27 10:59:28 douglis Exp $
  158. %
  159. /psf$TeXscale { 65536 div } def
  160.  
  161. %  x y bb-llx bb-lly bb-urx bb-ury startFig -
  162. /startTexFig {
  163.     /psf$SavedState save def
  164.     userdict maxlength dict begin
  165.  
  166.         Resolution 72 div dup neg scale
  167.         currentpoint translate    %set the current point as the user's origin
  168.  
  169.     /psf$ury exch psf$TeXscale def
  170.     /psf$urx exch psf$TeXscale def
  171.     /psf$lly exch psf$TeXscale def
  172.     /psf$llx exch psf$TeXscale def
  173.     /psf$y exch psf$TeXscale def
  174.     /psf$x exch psf$TeXscale def
  175.     
  176.     currentpoint /psf$cy exch def /psf$cx exch def
  177.  
  178.     /psf$sx psf$x psf$urx psf$llx sub div def     % scaling for x
  179.     /psf$sy psf$y psf$ury psf$lly sub div def    % scaling for y
  180.  
  181.     psf$sx psf$sy scale            % scale by (sx,sy)
  182.  
  183.     psf$cx psf$sx div psf$llx sub
  184.     psf$cy psf$sy div psf$ury sub translate
  185.     
  186.     /showpage {
  187.     } def
  188.     /erasepage {
  189.     } def
  190.     /copypage {
  191.     } def
  192.     @MacSetUp
  193. } def
  194.  
  195. % llx lly urx ury doclip -    (args in figure coordinates)
  196. /doclip {
  197.         psf$llx psf$lly psf$urx psf$ury
  198.     currentpoint 6 2 roll
  199.     newpath 4 copy
  200.     4 2 roll moveto
  201.     6 -1 roll exch lineto
  202.     exch lineto
  203.     exch lineto
  204.     closepath clip
  205.     newpath
  206.     moveto
  207. } def
  208. % - endTexFig -
  209. /endTexFig { end psf$SavedState restore } def
  210.  
  211. % this will be invoked as the result of a \special command (for the
  212. % inclusion of PostScript graphics).  The basic idea is to change all
  213. % scaling and graphics back to defaults, but to shift the origin
  214. % to the current position on the page.
  215.  
  216. /@beginspecial          % - @beginspecial -     -- enter special mode
  217.   { SDict begin
  218.     /SpecialSave save def
  219.     gsave
  220.     Resolution 72 div dup neg scale
  221.     currentpoint translate    %set the current point as the user's origin
  222.     @SpecialDefaults    % setup default offsets, scales, sizes, and angle
  223.   } bdf
  224.  
  225. /@setspecial    % to setup user specified offsets, scales, sizes (for clipping)
  226.   {
  227.     CLIP
  228.       { newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto 
  229.         closepath clip }
  230.       { initclip }
  231.     ifelse
  232.     ho vo translate
  233.     hsc vsc scale
  234.     ang rotate
  235.     BBcalc
  236.       { rwi urx llx sub div dup scale
  237.         llx neg lly neg translate }
  238.     if
  239.     /showpage {} def
  240.     newpath
  241.   } bdf
  242.  
  243. /@endspecial            % - @endspecial -       -- leave special mode
  244.   { grestore clear SpecialSave restore
  245.     end
  246.   } bdf
  247. /@defspecial
  248.   {
  249.     SDict begin
  250.   } bdf
  251. /@fedspecial
  252.   {
  253.     end
  254.   } bdf
  255.  
  256. %%% macros for tpic
  257. /li             % x y li -              -- draw line to
  258.   { lineto
  259.   } bdf
  260.  
  261. /rl             % dx dy rl -            -- draw relative line
  262.   { rlineto
  263.   } bdf
  264.  
  265. /rc             % x0 y0 x1 y1 y2 y2 rc  -- draw bezier curve
  266.   { rcurveto
  267.   } bdf
  268.  
  269. /np        % np -            -- start a new path and save currenpoint
  270.   { /SaveX currentpoint /SaveY exch def def   % remember current point
  271.     newpath
  272.   } bdf
  273.  
  274. /st             % st -                  -- draw the last path and restore currentpoint
  275.   { stroke
  276.     SaveX SaveY moveto                  % restore the current point
  277.   } bdf
  278.  
  279. /fil             % fil                    -- fill the last path and restore currentpoint
  280.   { fill
  281.     SaveX SaveY moveto                  % restore the current point
  282.   } bdf
  283.  
  284. /ellipse        % xc yc xrad yrad startAngle endAngle ellipse
  285.     {
  286.         /endangle exch def
  287.         /startangle exch def
  288.         /yrad exch def
  289.         /xrad exch def
  290.  
  291.         /savematrix matrix currentmatrix def
  292.  
  293.         translate
  294.         xrad yrad scale
  295.         0 0 1 startangle endangle arc
  296.         savematrix setmatrix
  297.     } bdf
  298. %%% end of macros for tpic
  299. end                     % revert to previous dictionary
  300.